import React, { Component } from 'react'
import './index.css'
import PubSub from 'pubsub-js'

export default class Menu extends Component {
   state={flag: false,mouseOverFlag: false}
   token= PubSub.subscribe('laogao',(msg,data)=>{
    console.log('@',data) 
    this.setState({flag: data})
  })

  handleonMouseOver=()=>{
    console.log('@',this.state.mouseOverFlag)
    PubSub.publish("mouseover",this.state.mouseOverFlag)
  }

componentWillUnmount(){
  PubSub.unsubscribe(this.token)  
}
  render() {
    return (
      <div>
        {
          this.state.flag?null:(
            <div className="navigation-menu1" onMouseOver={this.handleonMouseOver}>一级导航</div>
          )
        }
      </div>
      
    )
  }
}
